<!--搜索页-->
<script setup>
import {onMounted, ref} from "vue";
import {get} from "../util/Request.js";
import {Toast} from "tdesign-mobile-vue";

import router from "../router/index.js";


    const handleClick = () => {
      window.history.back() // 返回上一级页面
    };


const value=localStorage.getItem("value")
const content = ref(value.trim());

const images=ref([])
  onMounted(()=> {
    get("tbBook/find?bookName="+value).then(r => {
      if (r.code == 0) {
        images.value = r.data.records
      } else {
        Toast(r.data)
      }
    })
  })

const jianjie=(r)=>{
  localStorage.setItem("bookName",r)
  router.push("/aiw")
}

</script>

<template>
  <div>
    <t-navbar title="搜索结果" :fixed="false" left-arrow @left-click="handleClick" />

  </div>
  <div style="margin-top: 2%">
    <t-notice-bar style="width: 85%;margin-left: 3%;" class="notice-bar-demo-block" visible :prefix-icon="false" marquee :content="content" />
  </div>
  <div>
    <div class="image-demo" style="padding: 0 8px;margin-top: 3%;width:95%;height:100%;flex-wrap: wrap;display: flex">
      <div v-for="image in images" @click="jianjie(image.bookName)" style="width: 108px; height: 210px; margin-left: 1.2%;">
        <t-image :src="image.bookImg" class="image-container" style="width: 108px; height: 70%;" />
        <p class="image-demo-tip">{{ image.bookName }}</p>
      </div>
    </div>
  </div>
</template>

<style scoped>

</style>